import 'package:ball_lion/module/pick/items/expert_record_tag.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ball_lion/entity/expert/zq_hot_expert_entity.dart';
import 'package:ball_lion/utils/utils.dart';
import 'package:ball_lion/module/expert/items/expert_logo.dart';

import 'package:ball_lion/utils/mode_config.dart';
import 'package:ball_lion/routes/routes.dart';
import 'package:ball_lion/widgets/base/wqs_text.dart';

class HotExpertItem extends StatelessWidget {
  const HotExpertItem({
    super.key,
    required this.entity,
    required this.sportsId,
    this.eventType,
  });

  final HotExpertEntity? entity;
  final int sportsId;
  final String? eventType;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        if (eventType != null) {
          Utils.onEvent(eventType!, params: {eventType!: entity?.expertId});
        }
        // String index = "quanbu";
        // if(sportsId == 1){
        //   index = "zq";
        // }else if(sportsId == 2){
        //   index = "lq";
        // }
        // Get.toNamed(
        //   Routes.userPage,
        //   arguments: entity?.expertId,
        //   parameters: {'type': '2','index':index}
        // );
        if (entity?.liveInfo?.liveId.hasValue ?? false) {
          if (entity?.liveInfo?.bindMatch == 1) {
            Get.toNamed(
                entity?.liveInfo?.liveSportsId == 1
                    ? Routes.zqMatchDetail
                    : Routes.lqMatchDetail,
                arguments: entity?.liveInfo?.matchId,
                parameters: {"roomId": "${entity?.liveInfo?.liveId}"});
          } else {
            Get.toNamed(Routes.liveNormal, arguments: entity?.liveInfo?.liveId);
          }
        } else {
          String index = "quanbu";
          if (sportsId == 1) {
            index = "zq";
          } else if (sportsId == 2) {
            index = "lq";
          }
          Get.toNamed(Routes.userPage,
              arguments: entity?.expertId,
              parameters: {'type': '2', 'index': index});
        }
      },
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        mainAxisSize: MainAxisSize.min,
        children: [
          ExpertLogo(
            logo: entity?.logo,
            inLive: entity?.liveInfo?.liveId.hasValue == true,
            hasAuth: entity?.isInvite == 1,
            size: 40,
            planCnt: entity?.viewCnt,
          ),
          const SizedBox(height: 4, width: 10),
          QsText(
            entity?.name ?? '',
            fontSize: 12,
            fontWeight: FontWeight.w500,
            maxLines: 1,
          ),
          if (ModeConfig.expertRecord) ...[
            const SizedBox(height: 3, width: 10),
            ExpertRecordTag(
              text: "${entity?.value}",
              type: 6,
              textSize: 11,
              fontWeight: FontWeight.w500,
            )
          ]
        ],
      ),
    );
  }
}
